package projet_v1.simulation;

import static org.junit.Assert.*;

import java.util.List;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import projet_v1.Character;
import projet_v1.Item;
import projet_v1.items.help.FirstAidKit;
import projet_v1.items.help.Food;

/**
 * 
 * @author Romain Roufast
 *
 */
public class TestField {
	
	private Field f;

	@Before
	public void setUp() throws Exception {
		f = new Field(8,8);
	}

	@After
	public void tearDown() throws Exception {
		f = null;
	}
	

	/**
	 * This methods tests placeItem & getItem too
	 */
	@Test
	public void testClearItems() {
		f.placeItem(new Food(), 2, 2);
		List i = f.getItemsAt(2, 2);
		assertEquals(1, i.size());
		f.clearItems(new Location(2, 2));
		i = f.getItemsAt(2, 2);
		assertEquals(null, i);
	}


	@Test
	public void testRemoveItemAt() {
		FirstAidKit item = new FirstAidKit();
		f.placeItem(new Food(), 2, 2);
		f.placeItem(item, 2, 2);
		List i = f.getItemsAt(2, 2);
		assertEquals(2, i.size());
		f.removeItemAt(new Location(2, 2), item);
		i = f.getItemsAt(2, 2);
		assertEquals(1, i.size());
	}
	
	
	@Test
	public void testAdjacentLocations() {
		// If the start location is in a corner
		List<Location> l = f.adjacentLocations(new Location(2, 7), 2);
		assertEquals(14, l.size());
		// If the start location is in a corner
		l = f.adjacentLocations(new Location(4, 4), 2);
		assertEquals(24, l.size());
	}

}
